package reduce.fz.com.reduce.custom;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import reduce.fz.com.reduce.R;

/**
 * Created by qingshengzheng on 15/11/9.
 */
public class LeftMenuItem extends LinearLayout {
    private LayoutInflater layoutInflater;
    private Context context;
    //左側
    private ImageView mLeftMenuImage;
    private TextView mLeftMenuTitle;


    public LeftMenuItem(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        this.layoutInflater = LayoutInflater.from(context);
        initView();
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LeftMenuItem);
        String title = a.getString(R.styleable.LeftMenuItem_lmi_title);
        int imageid = a.getResourceId(R.styleable.LeftMenuItem_lmi_src, -1);
        mLeftMenuTitle.setText(title);
        mLeftMenuImage.setImageResource(imageid);
        a.recycle();
    }
    public void initView() {
        View view = layoutInflater.inflate(R.layout.view_left_menu_item, null);
        mLeftMenuImage = (ImageView) view.findViewById(R.id.left_menu_image);
        mLeftMenuTitle = (TextView) view.findViewById(R.id.left_menu_title);
    }
}
